package com.burstly.lib.currency.request;

import com.burstly.lib.currency.AccountInfo;
import com.burstly.lib.currency.BalanceUpdateInfo;
import com.burstly.lib.currency.secured.SecuredRequestBuilder;
import com.burstly.lib.feature.currency.ICurrencyListener;
import com.burstly.lib.network.request.CurrencyRequestTask;
import com.burstly.lib.util.LoggerExt;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

class RequestBalanceResetRunnable
  implements Runnable
{
  static final LoggerExt LOG = LoggerExt.getInstance();
  static final int MS_IN_SEC = 1000;
  static final String TAG = RequestBalanceResetRunnable.class.getSimpleName();
  private final List<ICurrencyListener> mListeners;
  final AccountInfo mNewAccountInfo;

  RequestBalanceResetRunnable(AccountInfo paramAccountInfo, List<ICurrencyListener> paramList)
  {
    this.mNewAccountInfo = paramAccountInfo;
    this.mListeners = paramList;
  }

  private void notifyListeners(Map<String, BalanceUpdateInfo> paramMap, boolean paramBoolean)
  {
    if (!this.mListeners.isEmpty());
    while (true)
    {
      ICurrencyListener localICurrencyListener;
      try
      {
        Iterator localIterator = this.mListeners.iterator();
        if (localIterator.hasNext())
        {
          localICurrencyListener = (ICurrencyListener)localIterator.next();
          if (paramBoolean)
            break label98;
          localICurrencyListener.didFailToUpdateBalance(paramMap);
          continue;
        }
      }
      catch (Exception localException)
      {
        LoggerExt localLoggerExt = LOG;
        String str = TAG;
        Object[] arrayOfObject = new Object[1];
        arrayOfObject[0] = localException.getLocalizedMessage();
        localLoggerExt.logWarning(str, "Uncaught Exception occured in currency listener: {0}", arrayOfObject);
      }
      return;
      label98: localICurrencyListener.didUpdateBalance(paramMap);
    }
  }

  private ResetAccountBalance prepareRequest(AccountInfo paramAccountInfo)
  {
    ResetAccountBalance localResetAccountBalance = new ResetAccountBalance();
    localResetAccountBalance.setPublisher(paramAccountInfo.getPubId());
    LOG.logDebug(TAG, "Reset balance object is: {0}", new Object[] { localResetAccountBalance });
    return localResetAccountBalance;
  }

  void notifyReset(boolean paramBoolean)
  {
    notifyListeners(new HashMap(), paramBoolean);
  }

  protected void onResetFinished()
  {
  }

  public void run()
  {
    ResetAccountBalance localResetAccountBalance = prepareRequest(this.mNewAccountInfo);
    new CurrencyRequestTask(new SecuredRequestBuilder().setData(localResetAccountBalance).buildResetAccountRequest(), AccountBalanceChangeResponse.class)
    {
      protected AccountBalanceChangeResponse performInBackground()
      {
        AccountBalanceChangeResponse localAccountBalanceChangeResponse = (AccountBalanceChangeResponse)super.performInBackground();
        RequestBalanceResetRunnable.LOG.logDebug(RequestBalanceResetRunnable.TAG, "Reset balance object is : {0}", new Object[] { localAccountBalanceChangeResponse });
        if (localAccountBalanceChangeResponse != null)
        {
          LoggerExt localLoggerExt = RequestBalanceResetRunnable.LOG;
          String str = RequestBalanceResetRunnable.TAG;
          Object[] arrayOfObject = new Object[2];
          arrayOfObject[0] = localAccountBalanceChangeResponse.getStatusCode();
          arrayOfObject[1] = localAccountBalanceChangeResponse.getMessage();
          localLoggerExt.logDebug(str, "Reset request finished with \"{0}\" code and \"{1}\" message.", arrayOfObject);
        }
        RequestBalanceResetRunnable.this.onResetFinished();
        return null;
      }
    }
    .execute(new Void[0]);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.currency.request.RequestBalanceResetRunnable
 * JD-Core Version:    0.6.2
 */